package com.provawidget;

import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProvider;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.widget.RemoteViews;


public class ProvaWidget extends AppWidgetProvider {

	private static final ComponentName THIS_WIDGET = new ComponentName("com.provawidget", "com.provawidget.ProvaWidget");
	private static int num = 0;
	
	@Override
	public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
		RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.main);
		views.setTextViewText(R.id.text, "Ciao " + num);
		num++;
		
		appWidgetManager.updateAppWidget(appWidgetIds, views);
	}
	
	@Override
	public void onReceive(Context context, Intent intent) {
		RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.main);
		views.setTextViewText(R.id.text, "Ciao " + num);
		num++;
		
		AppWidgetManager.getInstance(context).updateAppWidget(THIS_WIDGET, views);
		
		super.onReceive(context, intent);
	}
}
